import 'package:lcapp/api/request/api_client.dart';
import 'package:lcapp/api/request/response_data.dart';

class HomeAPI {

  static Future<ResponseData> getXianTypes() async {
    ResponseData responseData = await ApiClient.get("/api/merchandiseType/merchandiseTypes",);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> saveVideo(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/api/video/setVideo",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> saveSold(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/api/merchandise/save",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> saveCaigou(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/api/merchandise/purchase",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getXianHuos(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/api/merchandise/list",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getHotXianHuos() async {
    ResponseData responseData = await ApiClient.get("/api/merchandise/hotList");
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getVideos(int page,int size) async {
    ResponseData responseData = await ApiClient.post("/api/video/lab/timeranking",data: {
      'page':page,
      'size':size
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getVideoById(String vid) async {
    ResponseData responseData = await ApiClient.get("/api/video/videodetail/$vid");
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getAttentionVideos(int page,int size) async {
    ResponseData responseData = await ApiClient.post("/api/video/attention",data: {
      'page':page,
      'size':size
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> addPlayVideoViews(int videoid) async {
    ResponseData responseData = await ApiClient.post("/api/video/add/playCount",data: {
      'videoid':videoid,
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> likeVideo(int videoid,int uid) async {
    ResponseData responseData = await ApiClient.post("/api/alike/alikevideo",data: {
      'videoid':videoid,
      'issueid':uid
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getXianDetail(int xid) async {
    ResponseData responseData = await ApiClient.get("/api/merchandise/$xid");
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> addSearchValue(String search) async {
    ResponseData responseData = await ApiClient.post("/api/search/addsearchhistory",data: {'search':search});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getSearchValues() async {
    ResponseData responseData = await ApiClient.post("/api/search/interest",);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> searchVideos(int page,int size,String search) async {
    ResponseData responseData = await ApiClient.post("/api/video/search",data: {
      'search':search,
      'page':page,
      'size':size
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> sendMsgToShop(String phone) async {
    ResponseData responseData = await ApiClient.post("/api/message/sendMerchandiseInterest",data: {
      'phone':phone,
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> sendMsgToShopHome(String phone) async {
    ResponseData responseData = await ApiClient.post("/api/message/relationmerchant",data: {
      'phone':phone,
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> changeXianhuoStatus(int xid,int status) async {
    ResponseData responseData = await ApiClient.post("/api/merchandise/stopMerch",data: {
      'id':xid,
      'status':status
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> changeXianhuoPrice(int xid,String numbers,String price,int productUnit) async {
    ResponseData responseData = await ApiClient.post("/api/merchandise/updatePrice",data: {
      'id':xid,
      'numbers':numbers,
      'price':price,
      'productUnit':productUnit
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

}